﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

using System.Configuration;
using TGIApp.Model;

namespace TGIApp.Web.Controllers
{
    public class VenueController : Controller
    {
        //
        // GET: /Venue/

        public ActionResult Index()
        {
            var proxy = new Proxy.ServiceProxy();
            var venues = proxy.GetAllVenues();
            return View(venues);
        }

        //
        // GET: /Venue/Details/5

        public ActionResult Details(int id)
        {
            var proxy = new Proxy.ServiceProxy();
            var venue = proxy.GetVenueById(id);
            return View(venue);
        }

        //
        // GET: /Venue/Create

        public ActionResult Create()
        {
            return View();
        }

        //
        // POST: /Venue/Create

        [HttpPost]
        public ActionResult Create(Venue venue)
        {
            if (ModelState.IsValid)
            {
                ITgiService proxy = new Proxy.ServiceProxy();
                proxy.CreateVenue(venue);
            }
            return RedirectToAction("Index");
        }

        //
        // GET: /Venue/Edit/5

        public ActionResult Edit(int id)
        {
            ITgiService proxy = new Proxy.ServiceProxy();
            var venue = proxy.GetVenueById(id);
            return View(venue);
        }

        //
        // POST: /Venue/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, Venue venue)
        {
            if (ModelState.IsValid)
            {
                ITgiService proxy = new Proxy.ServiceProxy();
                proxy.UpdateVenue(venue);
            }
            return RedirectToAction("Index");
        }

        //
        // GET: /Venue/Delete/5

        public ActionResult Delete(int id)
        {
            ITgiService proxy = new Proxy.ServiceProxy();
            var venue = proxy.GetVenueById(id);
            return View(venue);
        }

        //
        // POST: /Venue/Delete/5

        [HttpPost]
        public ActionResult Delete(int id, Venue venueToBeDeleted)
        {
            ITgiService proxy = new Proxy.ServiceProxy();
            proxy.DeleteVenueById(id);
            return RedirectToAction("Index");
        }
    }
}
